package shopping.service.impl;

import shopping.dao.AdminDao;
import shopping.dao.impl.AdminDaoImpl;
import shopping.bean.Admin;
import shopping.service.AdminService;

public class AdminServiceImpl implements AdminService {

    private AdminDao adminDao = new AdminDaoImpl();

    @Override
    public void registAdmin(Admin admin) {
        adminDao.saveAdmin(admin);
    }

    @Override
    public Admin login(Admin admin) {
        return adminDao.queryAdminByAdminnameAndPassword(admin.getAdminname(), admin.getPassword());
    }

    @Override
    public boolean existsAdminname(String adminname) {

        if (adminDao.queryAdminByAdminname(adminname) == null) {
           // 等于null,说明没查到，没查到表示可用
           return false;
        }

        return true;

    }
}
